package pt.iul.dcti.poo.financemanager.gui;

import pt.iul.dcti.poo.financemanager.PersonalFinanceManager;
import pt.iul.dcti.poo.financemanager.categories.Category;
import pt.iul.dcti.poo.utils.Menu;

public class PersonalFinanceManagerUserInterface {

	private PersonalFinanceManager personalFinanceManager = new PersonalFinanceManager();
	private String f = "";

	public PersonalFinanceManagerUserInterface(PersonalFinanceManager personalFinanceManager) {
		this.setPersonalFinanceManager(personalFinanceManager);
	}

	private static final String OPT_SUMMARY = "Summary";
	private static final String OPT_SAVINGS = "Savings";
	private static final String OPT_HOME = "Home";
	private static final String OPT_EXTRA = "Extra";

	private static final String OPT_GLOBAL_POSITION = "Posi��o Global";
	private static final String OPT_ACCOUNT_STATEMENT = "Movimentos Conta";
	private static final String OPT_LIST_CATEGORIES = "Listar categorias";
	private static final String OPT_ANALISE = "An�lise";
	private static final String OPT_EXIT = "Sair";

	private static final String OPT_MONTHLY_SUMMARY = "Evolu��o global por m�s";
	private static final String OPT_PREDICTION_PER_CATEGORY = "Previs�o gastos totais do m�s por categoria";
	private static final String OPT_ANUAL_INTEREST = "Previs�o juros anuais";

	private static final String[] OPTIONS_INITIAL = { OPT_SUMMARY, OPT_SAVINGS, OPT_HOME , OPT_EXTRA };
	private static final String[] OPTIONS_ANALYSIS = { OPT_MONTHLY_SUMMARY, OPT_PREDICTION_PER_CATEGORY, OPT_ANUAL_INTEREST}; 
	private static final String[] OPTIONS_EXTRA = { OPT_GLOBAL_POSITION, OPT_ACCOUNT_STATEMENT, OPT_LIST_CATEGORIES, OPT_ANALISE, OPT_EXIT };


	public void execute() {
		while(f == ""){
			//menuInitial();
			menuExtra();
		}
	}

	/*public void menuInitial(){
		Menu menuInitial = new Menu();
		String name = "";
		name =  menuInitial.requestSelection(name, OPTIONS_INITIAL);

		switch(name){
		case OPT_SUMMARY:
			break;
		case OPT_SAVINGS:
			break;
		case OPT_HOME:
			break;
		case OPT_EXTRA:
			menuExtra();
			break;
		default:
			break;
		}
	}*/

	public void menuExtra(){
		Menu menuExtra = new Menu();
		String name = "";
		name = menuExtra.requestSelection(name, OPTIONS_EXTRA);

		switch (name) {
		case OPT_GLOBAL_POSITION:
			personalFinanceManager.menuPosicaoGlobal();
			break;
		case OPT_ACCOUNT_STATEMENT:
			personalFinanceManager.menuMovimentosContas();
			break;
		case OPT_LIST_CATEGORIES:
	//		personalFinanceManager.menuListarCategorias();
			break;
		case OPT_ANALISE:
			menuAnalise();
			break;
		case OPT_EXIT:
			exit();
			break;
		default:	
			break;
		}
	}
	
	private void exit(){
		Menu sair = new Menu();
		sair.yesOrNoInput("Save?");//TODO falta: se sim acaba o programa; se n�o ou cancelar volta ao menu
	}

	public void menuAnalise(){
		Menu menuAnalise= new Menu();
		String name = "";
		name = menuAnalise.requestSelection(name, OPTIONS_ANALYSIS);

		switch(name){
		case OPT_MONTHLY_SUMMARY:
			personalFinanceManager.menuEvolucaoGlobalMes();
			break;
		case OPT_PREDICTION_PER_CATEGORY:
			break;
		case OPT_ANUAL_INTEREST:
			break;
		default:
			break;
		}
	}

	public PersonalFinanceManager getPersonalFinanceManager() {
		return personalFinanceManager;
	}

	public void setPersonalFinanceManager(PersonalFinanceManager personalFinanceManager) {
		this.personalFinanceManager = personalFinanceManager;
	}
}
